stage.set_background("moon")
sprite = codesters.Sprite("hedgehog", 0, -210)
points = 0
score_board = codesters.Display(points, -209, -209)
time = 60
timer_board = codesters.Display(time, 194,-197)
def interval():
global time
time -=1
timer_board.update(time)
if time %2 == 0:
x = random.randint(-230,230)
y = random.randint(0,230)
star = codesters.Star(x, y, 5, 20, "yellow")
if time == 0:
stage.remove_all_events()
text = codesters.Text("HEDGEY SCORED "+ str(points) + " POINTS!", -21, -176, "red")
stage.event_interval(interval, 1)
def left():
rotation = sprite.get_rotation()
sprite.set_rotation(rotation+3)
stage.event_key("left", left)
def right():
rotation = sprite.get_rotation()
sprite.set_rotation(rotation-3)
stage.event_key("right", right)
def release_key():
sprite.say("BLAST OFF !", 1, "white")
sprite.move_forward(575)
stage.wait(0.1)
sprite.go_to(0, -210)
stage.event_key_release("space", release_key)
def collision(star, hit_sprite):
global points
points += 1
stage.remove_sprite(hit_sprite)
score_board.update(points)
sprite.event_collision(collision)
tester = TestManager()
tester.display_success_message("Great job!")
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)